-
-
Notifications
You must be signed in to change notification settings - Fork 5.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support completable animations in Compose tests #2051
Conversation
44a573d
to
e9db247
Compare
return if (iterations == LottieConstants.IterateForever) { | ||
// We use withInfiniteAnimationFrameNanos because it allows tests to add a CoroutineContext | ||
// element that will cancel infinite transitions instead of preventing composition from ever going idle. | ||
withInfiniteAnimationFrameNanos { frameNanos: Long -> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
withInfiniteAnimationFrameNanos { frameNanos: Long -> | |
withInfiniteAnimationFrameNanos { frameNanos -> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
right, fixed this copy paste
onFrame(iterations, frameNanos) | ||
} | ||
} else { | ||
withFrameNanos { frameNanos: Long -> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
withFrameNanos { frameNanos: Long -> | |
withFrameNanos { frameNanos -> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
right, fixed this copy paste
e9db247
to
9ef8491
Compare
The change in #1987 to always use
withInfiniteAnimationFrameNanos
prevents non-infinite animations from completing in Compose tests.I added a simple check to use
withFrameNanos
orwithInfiniteAnimationFrameNanos
based on the number of iterations. This fixes tests that wait for animations to complete, see sampleWalkthroughAnimationTest
. AndInfiniteAnimationTest
still passes.Let me know if I'm missing some other use case.